<template>
    <page-main title="考核评定" title-icon="dashboard">
        <div slot="title-left">
            <ul class="flex">
                <li v-for="(item,index) in numberList" :key="index+1" class="examine-header-number">
                    {{ item.label }}
                    <count-to class="num" :start-val="0" :end-val="item.number" :duration="2200"/>
                </li>
            </ul>
        </div>

        <div class="examine-select flex justify-between">
            <div class="select-left">
                <el-radio-group v-model="selectVal" size="medium">
                    <el-radio-button label="0">
                        全部
                    </el-radio-button>
                    <el-radio-button label="1">
                        已评定
                    </el-radio-button>
                    <el-radio-button label="2">
                        待评定
                    </el-radio-button>
                    <el-radio-button label="3">
                        实习中
                    </el-radio-button>
                </el-radio-group>
            </div>
            <div class="select-right">
                <el-input
                    v-model="input"
                    placeholder="班级，组"
                    clearable
                />
            </div>
        </div>

        <div class="examine-list">
            <el-row :gutter="20">
                <el-col v-for="(item,index) in examineList" :key="index+1" :lg="6" :md="8" :sm="12"
                        style="margin-bottom: 10px;"
                >
                    <el-card shadow="hover" class="examine-card">
                        <router-link to="/examine/index/detail">
                            <div class="examine-card-item">
                                <h2>{{ item.title }}</h2>
                                <div class="text-grey">
                                    {{ item.group }}组
                                </div>
                                <div class="text-grey">
                                    组长：{{ item.groupLeader }}
                                </div>
                                <el-row :gutter="8">
                                    <el-col v-for="(data,dataIndex) in item.groupMember" :key="dataIndex+1" :span="12"
                                            style="margin-bottom: 10px;"
                                    >
                                        组员：{{ data }}
                                    </el-col>
                                </el-row>
                            </div>
                            <div class="examine-card-actions">
                                <el-button v-if="item.isReview" type="info">
                                    完成评定
                                </el-button>
                                <el-button v-else type="danger">
                                    待评定
                                </el-button>
                            </div>
                        </router-link>
                    </el-card>
                </el-col>
            </el-row>
        </div>
    </page-main>
</template>

<script>
import PageMain from '@/components/PageMain'
import countTo from 'vue-count-to'

export default {
    name: 'Index',
    components: {PageMain, countTo},
    data() {
        return {
            numberList: [
                {
                    label: '总数',
                    number: 12
                },
                {
                    label: '已评定',
                    number: 6
                },
                {
                    label: '待评定',
                    number: 12
                },
                {
                    label: '实习中',
                    number: 2
                }
            ],
            selectVal: '0',
            input: '',
            examineList: []
        }
    },
    mounted() {
        const dataSource = []
        for (let i = 0; i < 11; i++) {
            dataSource.push({
                title: '物理 2019级3班',
                group: 'A01',
                groupLeader: '王虎',
                groupMember: ['1', '2', '3', '4'],
                endTime: '2021年12月1日',
                id: i + 1,
                isReview: i % 2 === 0
            })
        }
        this.examineList = dataSource
    }
}
</script>

<style scoped lang="scss">
.examine-header-number {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 15px;
    margin: 0 12px;
    color: #aaa;
    position: relative;
    span {
        margin-top: 10px;
        font-size: 20px;
        font-weight: bold;
        color: #333;
    }
}
.examine-list {
    margin-top: 15px;
    .examine-card-item {
        text-align: center;
        font-size: 14px;
        .text-grey {
            margin-bottom: 10px;
        }
        h2 {
            font-weight: bold;
        }
        .examine-card-item-time {
            margin-top: 10px;
        }
    }
    .examine-card-actions {
        display: flex;
        justify-content: space-around;
        margin: 25px -20px -20px;
        margin-bottom: 2px;
    }
}
</style>
